﻿	      <?php include("conn.php");
             mysql_query('SET NAMES UTF8'); 

	  

class MyPrizeBean
{

	public $code;

	function __construct($code)
	{
		
	$this->code      = $code;
	}
}


	$prize = array();
	
 if($_REQUEST[userid]!="")
 {         

		  //取消点赞
 if($_REQUEST[quxiao]!="")
 {    
 
  $srat1=mysql_query("DELETE FROM talklike where talkid ='".$_REQUEST[talkid]."' and  userid ='".$_REQUEST[userid]."'");
  
      if($srat1!=false)
          { 
	 $srat=mysql_query("update talks set xihuan=xihuan-1 where id ='".$_REQUEST[talkid]."'");
	      }
		  
        $der=100;
 }else { 
 //取消点赞 end 

$rert=mysql_query("select *from talklike   where talkid ='".$_REQUEST[talkid]."' and  userid ='".$_REQUEST[userid]."'");
$rowf=mysql_fetch_array($rert);

    

 
 if($rowf!=true)
 {
 
 

$srat=mysql_query("INSERT INTO talklike(userid,talkid) VALUES ('$_REQUEST[userid]','$_REQUEST[talkid]')");


   
	 
	$srat2=mysql_query("update talks set xihuan=xihuan+1 where id ='".$_REQUEST[talkid]."'");

	      if($srat!=false)
	     {
		  $der=100;
		  
		  }
		  
		  else{
			   $der=200;
		  }
		  
		  }
		  else
		  {
		  $der=300;
		  }
		  
		  

 }
	
		}
		 else
		  {
		   $der=300;
		  }

$prize[] = new MyPrizeBean($der);
echo json_encode($prize);


?>